begintownscript;

variables;
short choice;

body;

beginstate 0; //INIT_STATE
	if(get_flag(2,0) == 0) {
		reset_dialog();
		add_dialog_str(0,"This dock is fairly standard for the settled islands of Vantanas. It's nothing more than an anchored stone platform set into the beach.",0);
		add_dialog_str(1,"From here, you can see a few rowboats tied up at the dock, ready to ferry goods out to ships waiting off the coast.",0);
		add_dialog_str(1,"You should seek out the dockmaster before the boats are needed for something.",0);
		run_dialog(1);
		set_flag(2,0,1);
		}

	//General setup
	set_crime_tolerance(1);
	enable_add_chars(1);
	add_range_to_group(6,9,1); //guards
	add_char_to_group(15,1);
	set_name(1001,"Harbor Guard");
	set_character_pose(15,14);
	set_name(10,"Dockmaster Henric"); //dockmaster
	set_char_dialogue_pic(10,521,0);
	add_range_to_group(11,14,2); //sailors
	set_name(1002,"Sailor");
	set_level(1002,10);
	set_character_pose(14,14);
	force_instant_terrain_redraw();
break;

beginstate 1; //EXIT_STATE
break;

beginstate 2; //START_STATE
	//Checking for the lead pc each turn... not necessary here
	//pc_counter = 0;
	//while(char_ok(pc_counter) == 0) {
	//	pc_counter = pc_counter + 1;
	//	}
	//lead_char = pc_counter;
	
	//updating the signal fire
	if((get_current_tick() % 5000 + 250 >= 3750) && ((get_flag(2,5) == 0) || (get_terrain(19,22) == 271))) {
		set_terrain(19,22,209);
		force_instant_terrain_redraw();
		set_flag(2,5,1);
		}
	if((get_current_tick() % 5000 + 250 < 3750) && ((get_flag(2,5) == 1) || (get_terrain(19,22) == 209))) {
		set_terrain(19,22,271);
		force_instant_terrain_redraw();
		set_flag(2,5,0);
		}
	
break;

beginstate 10; //signal fire
	if(get_flag(2,1) == 1)
		end();
	reset_dialog();
	add_dialog_str(0,"You recognize this platform as a signal fire, a common safety feature on almost all Empire docks.",0);
	if(get_flag(2,5) == 0)
		add_dialog_str(1,"At the moment, it's not lit.",0);
	else
		add_dialog_str(1,"At the moment, it's lit.",0);
	run_dialog(1);
	set_flag(2,1,1);
break;

beginstate 15; //getting into the boat
	if(get_flag(2,2) != 1)
		end();
	reset_dialog();
	add_dialog_str(0,"As you start paddling, you very nearly flip over the side. A few moments of panicked balancing later, and you've managed to regain your balance.",0);
	add_dialog_str(1,"Slowly, you get a better handle on the oars, though the boat is now creaking ominously. With any luck, this thing will be enough to get you out to Copperpeak and back.",0);
	run_dialog(1);
	set_flag(2,2,2);
break;

beginstate 20; //leaving in a boat
	if(get_flag(2,3) != 0)
		end();
	reset_dialog();
	add_dialog_str(0,"You're finally starting to get the hang of this boat, and you slowly begin to ease your way out into open water. The waves start to pick up, and water starts to spill over the sides of the boat.",0);
	add_dialog_str(1,"A quick look out at the ocean tells you that this boat won't be able to handle the deeper ocean. You'll be much safer if you stay close to the shore.",0);
	run_dialog(1);
	set_flag(2,3,1);
break;

beginstate 25; //storeroom
	if(get_flag(2,4) == 1)
		end();
	reset_dialog();
	add_dialog_str(0,"This storeroom is rather unimpressive, by adventuring standards. No loose wealth, no magical items... it looks like there's nothing but junk in here.",0);
	run_dialog(1);
	set_flag(2,4,1);
break;

beginstate 30; //bunkhouse
	if(get_flag(2,6) == 1)
		end();
	reset_dialog();
	add_dialog_str(0,"This appears to be a bunkhouse for the guards and sailors who pass through here. It's not the cleanest place you've ever seen, but these people probably don't have a choice.",0);
	run_dialog(1);
	set_flag(2,6,1);
break;

beginstate 35; //bunkhouse
	if(get_flag(2,7) == 1)
		end();
	reset_dialog();
	add_dialog_str(0,"Wow... this room is full of paper. There's so much scattered around the room that you're not sure where you can step safely.",0);
	add_dialog_str(1,"A weary-looking bureaucrat sits at a desk in the center of the paper maelstrom, and he's smoking a pipe.",0);
	run_dialog(1);
	set_flag(2,7,1);
break;